using System.Runtime.InteropServices;

namespace Kise.LprCapturer
{
    public class VideoSpeedCalculator : ISpeedCalculator
    {
        public VideoSpeedCalculator(float leftTopX, float leftTopY, float rightTopX, float rightTopY, float leftBottomX, float leftBottomY, float rightBottomX, float rightBottomY, float realWidth, float realHeight, float ratio)
        {
            InitVelocietyMeasure(leftTopX, leftTopY, rightTopX, rightTopY, leftBottomX, leftBottomY, rightBottomX, rightBottomY, realWidth, realHeight, ratio);
        }

        public int CalcSpeed(int x1, int y1, int x2, int y2, int nanosecond)
        {
            return CalcVelociety1(x1, y1, x2, y2, nanosecond);
        }


        /// Return Type: void
        ///leftTopX: float
        ///leftTopY: float
        ///rightTopX: float
        ///rightTopY: float
        ///leftBottomX: float
        ///leftBottomY: float
        ///rightBottomX: float
        ///rightBottomY: float
        ///realWidth: float
        ///realHeight: float
        ///ratio: float
        [DllImport("VideoMeasureVelocity", EntryPoint = "InitVelocietyMeasure", CallingConvention = CallingConvention.Cdecl)]
        private static extern void InitVelocietyMeasure(float leftTopX, float leftTopY, float rightTopX, float rightTopY, float leftBottomX, float leftBottomY, float rightBottomX, float rightBottomY, float realWidth, float realHeight, float ratio);


        /// Return Type: int
        ///x1: int
        ///y1: int
        ///x2: int
        ///y2: int
        ///nanosecond: int
        [DllImport("VideoMeasureVelocity", EntryPoint = "CalcVelociety1", CallingConvention = CallingConvention.Cdecl)]
        private static extern int CalcVelociety1(int x1, int y1, int x2, int y2, int nanosecond);

    }
}